<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/9
 * Time: 15:35
 */
if (!defined('ACCESS')) {
    exit('Access denied.');
}

class Order extends DBBase
{

    private static $table_name = 'order_sn_record';
    // 查询字段
    private static $columns = array('id', 'order_sn', 'userid', 'shipping_method', 'pay_type', 'user_name', 'shipping_time', 'phone', 'line', 'addres', 'gender', 'email', 'note', 'status', 'createtime', 'modifytime');

    public static function getTableName()
    {
        return parent::$table_prefix . self::$table_name;
    }


    public static function add($function_data)
    {
        if (!$function_data || !is_array($function_data)) {
            return false;
        }
        $db = self::__instance();
        $id = $db->insert(self::getTableName(), $function_data);
        return $id;
    }

    public static function getById($id)
    {
        $condition = array('id' => $id);
        $db = self::__instance();
        $rt = $db->get(self::getTableName(), self::$columns, $condition);
        return $rt;
    }

    public static function getByOrderSn($sn)
    {
        $condition = array('order_sn' => $sn, "status" => "0");
        $db = self::__instance();
        $rt = $db->get(self::getTableName(), self::$columns, $condition);
        return $rt;
    }

    public static function getByCondition($condition)
    {
        $db = self::__instance();
        $rt = $db->get(self::getTableName(), self::$columns, $condition);
        return $rt;
    }

    public static function update($data, $oid)
    {
        if (!$data || !is_array($data)) {
            return false;
        }
        $condition = array('id' => $oid);
        $db = self::__instance();
        $id = $db->update(self::getTableName(), $data, $condition);
        return $id;
    }
}




